package cn.source.web.controller.gygl;
import cn.source.common.core.domain.AjaxResult;
import cn.source.system.websocket.WebSocket;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;
import javax.websocket.Session;
@RestController
@RequestMapping("/system/websocket")
public class MessageController {
    WebSocket webSocket;
    @GetMapping("index")
    public AjaxResult index(){
        return AjaxResult.success("请求成功");
    }
    @GetMapping("page")
    public ModelAndView page(){
        return new ModelAndView("websocket");
    }
    @RequestMapping("/sendCleanMessage/{toUserId}")
    public AjaxResult sendCleanMessage(String message , @PathVariable String toUserId) {
        webSocket.sendOneMessage(toUserId,message);
        return AjaxResult.success("发送成功");
    }
}
